package com.hzxy.yiyid.web.module.controller;

import com.hzxy.yiyid.web.common.base.BaseResult;
import com.hzxy.yiyid.web.common.error.ErrorCodeEnum;
import com.hzxy.yiyid.web.module.controller.vo.PenaltyInfoRequestVO;
import com.hzxy.yiyid.web.module.service.IdentifyDoctorService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @ClassName IdentifyDoctorController
 * @Description 慧眼识医
 * @Author RAICOM2023
 * @Date 2023/3/6 21:35
 * @Version 1.0
 **/
@Api(tags = "医生相关接口")
@Controller
@RequestMapping(value = "/doctor")
public class IdentifyDoctorController {

    private static final Logger logger = LoggerFactory.getLogger(IdentifyDoctorController.class);

    @Resource
    private IdentifyDoctorService identifyDoctorService;

    /*
     * @Author RAICOM2023
     * @Description //根据处罚对象名称查询处罚信息
     * @Date 22:03 2023/3/6
     * @Param [penaltyInfoRequestVO]
     * @return com.hzxy.yiyid.web.common.base.BaseResult<?>
     **/
    @ApiOperation(value = "获取惩罚信息列表",notes = "获取惩罚信息列表")
    @RequestMapping(value = "/getPenaltyInfoList", method = RequestMethod.POST)
    @ResponseBody
    public BaseResult<?> getPenaltyInfoList(@RequestBody PenaltyInfoRequestVO penaltyInfoRequestVO) {
        try{
            /*if(StringUtils.isBlank(penaltyInfoRequestVO.getYsCfdx())){
                return BaseResult.fail(ErrorCodeEnum.DOCTOR_PARAM_NULL_ERROR.getErrorCode(),ErrorCodeEnum.DOCTOR_PARAM_NULL_ERROR.getMsg());
            }*/
            if (null == penaltyInfoRequestVO.getPageNo()) {
                penaltyInfoRequestVO.setPageNo(1);
            }
            if (null == penaltyInfoRequestVO.getPageSize()) {
                penaltyInfoRequestVO.setPageSize(20);
            }
            Map<String, Object> returnMap = new HashMap<>();
            List<Map<String, Object>> penaltyInfoMapList =
                    identifyDoctorService.listPenaltyInfo(penaltyInfoRequestVO);
            long total = identifyDoctorService.findPenaltyTotal(penaltyInfoRequestVO);
            returnMap.put("list", penaltyInfoMapList);
            returnMap.put("total", total);
            return BaseResult.success(returnMap);
        }catch(Exception e){
            logger.error(ErrorCodeEnum.SYSTEM_ERROR.getMsg(),e);
            return BaseResult.error(ErrorCodeEnum.SYSTEM_ERROR.getErrorCode(),ErrorCodeEnum.SYSTEM_ERROR.getMsg());
        }
    }

}
